#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/5/9 22:15
# @Author  : Beam
# @File    : 协程greenlet.py

'''pip instal gevent'''
from greenlet import greenlet
'''gevent包含了greenlet'''
def t1():
    print(1)   #第二步
    gr2.switch() #第三步
    print(2) #第六步
    gr2.switch() #第七步

def t2():
    print(3)   #第四步
    gr1.switch() #第五步
    print(4)   #第八步

gr1 = greenlet(t1)   #启动一个协程
gr2 =greenlet(t2)
gr1.switch()    #第一步
